package test14;

import java.util.*;

/**
 * 单词倒排
 */
public class Main{
    public static void main(String[]args) {
        Scanner sc= new Scanner(System.in);
        
        while(sc.hasNextLine()) {
            String s = sc.nextLine();
            Stack<Character>stack = new Stack<>();
            for(int i=s.length()-1;i>=0;i--) {
                if( (s.charAt(i) >='A' && s.charAt(i)<='Z') || (s.charAt(i)>='a'&&s.charAt(i)<='z')){
                    stack.push(s.charAt(i));
                } else {
                    while(!stack.isEmpty()){
                       System.out.print( stack.pop());
                    }
                    while((i>= 0) && !((s.charAt(i) >='A' && s.charAt(i)<='Z') || (s.charAt(i)>='a'&&s.charAt(i)<='z')) ) {
                        i--;
                    }
                    i++;
                    System.out.print(' ');
                }
            }
            while(!stack.isEmpty()){
                System.out.print( stack.pop());
            }
            System.out.println();
        }
    }
}